package com.pfzy.utildemo.activity.im;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pfzy.utildemo.ConstsValue;
import com.pfzy.utildemo.R;

import java.util.Date;

public class ReceiveMessageView extends RelativeLayout {
    private TextView tvTimeStamp;
    private TextView receiveMessage;

    public ReceiveMessageView(Context context) {
        super(context, null);
        View view = View.inflate(context, R.layout.view_receive_message_item, this);
        tvTimeStamp = view.findViewById(R.id.timestamp);
        receiveMessage = view.findViewById(R.id.receiveMessage);
    }

    public void bindView(Message emMessage) {
        updateMessage(emMessage);
        updataTimestamp(emMessage);
    }

    private void updataTimestamp(Message emMessage) {
        String timeStr = com.hyphenate.util.DateUtils.getTimestampString(new Date(emMessage.getTime()));
        tvTimeStamp.setText(timeStr);
    }

    private void updateMessage(Message emMessage) {
        receiveMessage.setText(emMessage.getMessage());
    }
}
